import {
  getSourcesPathList
} from '@/api/barcodeprint/mesBarcodeprintLabels'
export const formDialogConfig = {
  data() {
    const that = this
    return {
      fontTypeOptions: [], // 字体样式下拉
      defaultFontOptions: [], // 默认字体下拉
      fontOptions: [], // 字体编码下拉
      searchConfig: {
        span: 24,
        disabled: false,
        isShowSubmitBtn: true,
        formDesc: {
          barcode: {
            type: "input",
            label: $i18n.t("mesScanRecord.barcode3"),
          },
          lineCode: {
            type: "select",
            label: $i18n.t("mesScanRecord.lineCode2"),
            prop: {
              value: "modelingCode",
              text: "modelingName",
            },
            options: async (data) => {
              const list = await getLineCodeList()
              return list.data.result
            },
          },
          // lineName: {
          //   type: "input",
          //   label: "生产线体名称",
          // },
          productProcessCode: {
            type: "select",
            label: $i18n.t("mesScanRecord.productProcessCode2"),
            prop: {
              value: "processCode",
              text: "processName",
            },
            options: async (data) => {
              const list = await getProductProcessCodeList()
              return list.data.result
            },
            // on: {
            //   change: (val) => {
            //     that.handleSelectLine(val)
            //   }
            // }
          },
          // productProcessName: {
          //   type: "input",
          //   label: "生产工序名称",
          // },
          workCellCode: {
            type: "select",
            label: $i18n.t("mesScanRecord.workCellCode2"),
            prop: {
              value: "value",
              text: "description",
            },
            options: async (data) => {
              const list = await getWorkCellCodeList()
              return list.data.result
            }
          },
          // workCellName: {
          //   type: "input",
          //   label: "采集工位名称",
          // },
          // workTeamCode: {
          //   type: "select",
          //   label: "采集班组编码",
          //   type: 'select',
          //   prop: {
          //     value: "value",
          //     text: "description",
          //   },
          //   options: async (data) => {
          //     const list = await getWorkTeamCodeList()
          //     return list.data.result
          //   },
          // },
          // workTeamName: {
          //   type: "input",
          //   label: "采集班组名称",
          // },
          userCode: {
            type: "input",
            label: $i18n.t("mesScanRecord.userCode2"),
            // type: 'select',
            // prop: {
            //   value: "value",
            //   text: "description",
            // },
            // options: async (data) => {
            //   const list = await getUserCodeList()
            //   return list.data.result
            // },
          },
          userName: {
            type: "input",
            label: $i18n.t("mesScanRecord.userName2"),
          },
          scanTime: {
            type: "datetimerange",
            label: $i18n.t("mesScanRecord.scanTime"),
            attrs: {
              valueFormat: "yyyy-MM-dd HH:mm:ss",
              searchArrKey: ["scanTimeMin", "scanTimeMax"]
            },
          },
          orderCode: {
            type: "input",
            label: $i18n.t("mesScanRecord.orderCode2"),
          },
          // prodCode: {
          //   type: "input",
          //   label: "产品编码",
          // },
          prodName: {
            type: "input",
            label: $i18n.t("mesScanRecord.prodName"),
          },
          // seriesCode: {
          //   type: "input",
          //   label: "系列编码",
          // },
          // seriesName: {
          //   type: "input",
          //   label: "系列名称",
          // },
          // simulatedType: {
          //   type: "select",
          //   label: "虚实订单类型",
          //   type: 'select',
          //   prop: {
          //     value: "value",
          //     text: "description",
          //   },
          //   options: async (data) => {
          //     const list = await getSimulatedTypeList()
          //     return list.data.result
          //   },
          // },
          // prodOrderType: {
          //   type: "select",
          //   label: "生产订单类型",
          //   type: 'select',
          //   prop: {
          //     value: "value",
          //     text: "description",
          //   },
          //   options: async (data) => {
          //     const list = await getProdOrderTypeList()
          //     return list.data.result
          //   },
          // },
        },
      }
    }
  },
  methods: {
    // 根据表名称获取数据源名称下拉数据
    handleChange(val) {
      if (!val) return
      const params = {
        tableName: val
      }
      getSourcesPathList(params)
        .then((res) => {
          const { result } = res.data
          this.formDescDialog.formDesc.sourcesPath.options = result || []
        })
        .catch((err) => {
          console.log(err)
        })
    },
    handleSelect(val, field, options) {
      if (!val) {
        this.formDataDialog[field] = undefined
      } else {
        const selected = options.find((item) => item.value == val)
        this.formDataDialog[field] = selected.description
      }
    }
  }
}
